﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Dialog.Master" AutoEventWireup="true" CodeBehind="ClientDialogBox.aspx.cs" Inherits="Legazpi.Payroll.Web.PopupBoxes.ClientDialogBox" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
    var serviceUrl = '<%=ResolveUrl("~/Webservices/EmployeeWebService.asmx")%>';
    $(document).ready(function () {
        $('#ClientSubmitButton').click(function () {
            var ClientObj = {
                Code: $('#ClientCode').val(),
                Description: $('#ClientDesc').val(),
                Address: $('#ClientAdress').val()
            };
            var json = JSON.stringify({ clientItem: ClientObj });
            BlockUI.BlockElementLoading("dialog", "Saving...", true, 4);
            $.ajax({
                type: "POST",
                url: serviceUrl + "/AddClient",
                data: json,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var response = eval('(' + data.d + ')');
                    if (response.Success) {
                        var dropDown = $('#' + Employee.ClientDropdownControlId);
                        dropDown.append("<option value='" + response.newItem.Id + "'>" + response.newItem.Code + "</option>")
                        alert('Saved!');
                        PopUpDialog.CloseDialog(Employee.ClientPopUpId);
                    }
                },
                complete: function () {
                    BlockUI.UnBlockElement("dialog");
                }
            });
        });
    });
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">

            <fieldset class="register">
                <legend>Client Details</legend>
                <p>
                    <label for="ClientCode">Code Label:</label>
                    <input type="text" id="ClientCode" class="textEntry" />
                </p>
                <p>
                    <label for="ClientDesc">Firm Name:</label>
                    <input type="text" id="ClientDesc" maxlength="100" class="textEntry" />
                </p>
                <p>
                    <label for="ClientName">Address:</label>
                    <textarea id="ClientAdress" class="textEntry" rows="3" cols="20">
                        
                    </textarea>                    
                </p>
            </fieldset>
            <p class="submitButton">
                <input type="button" id="ClientSubmitButton" value="OK" />
            </p>

</asp:Content>

